-- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.
DROP POLICY IF EXISTS "User RBAC with user_api_keys table and request table" on response;

CREATE OR REPLACE FUNCTION public.check_response_access(
      this_associated_request_id uuid)
      RETURNS boolean
      LANGUAGE 'sql'
      COST 100
      VOLATILE PARALLEL UNSAFE
  AS $BODY$
     SELECT EXISTS (select * from request r where r.id = this_associated_request_id)
  $BODY$;

CREATE POLICY "User RBAC with user_api_keys table and request table"
    ON public.response
    AS PERMISSIVE
    FOR SELECT
    TO public
    USING (check_response_access(request));